package com.example.demo.util;

import javax.servlet.http.HttpServletResponse;

public class BaseHttpParamPool {

    //记录请求对象
    private static ThreadLocal<RequestDto> requestThreadLocal = new ThreadLocal<>();
    //记录返回对象
    private static ThreadLocal<HttpServletResponse> responseThreadLocal = new ThreadLocal<>();
    //测试id
    private static ThreadLocal<String> stringThreadLocal = new ThreadLocal<>();

    public static void setHttpServletRequest(RequestDto req) {
        requestThreadLocal.set(req);
    }

    public static RequestDto getHttpServletRequest(){
        return requestThreadLocal.get();
    }

    public static void removeHttpServletRequest(){
        requestThreadLocal.remove();
    }

    public static void setId(String id){
        stringThreadLocal.set(id);
    }

    public static String getId(){
        return stringThreadLocal.get();
    }

    public static void removeId(){
        stringThreadLocal.remove();
    }


    public static void setHttpServletResponse(HttpServletResponse response){
        responseThreadLocal.set(response);
    }

    public static HttpServletResponse getHttpServletResponse(){
        return responseThreadLocal.get();
    }

    public static void removeHttpServletResponse(){
        responseThreadLocal.remove();
    }
}
